<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input v-model="filters.keyword" placeholder="请根据日志名称查询"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="search">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>

		<!--列表-->
		<el-table :data="logs" highlight-current-row v-loading="listLoading"  style="width: 100%;">
      <el-table-column type="selection" width="55">
      </el-table-column>
      <el-table-column type="index" width="60">
      </el-table-column>
      <el-table-column prop="name" label="日志名称" width="120" >
      </el-table-column>
      <el-table-column prop="methodName" label="获取的方法名" width="150" >
      </el-table-column>
      <el-table-column prop="hostAddress" label="当前电脑ip" width="120" >
      </el-table-column>
      <el-table-column prop="crateTime" label="访问时间">
      </el-table-column>
		</el-table>

		<!--工具条-->
		<el-col :span="24" class="toolbar">
      <!--分页组件-->
			<el-pagination layout="prev, pager, next"
                     @current-change="handleCurrentChange"
                     :page-size="pageSize"
                     :current-page="currentPage"
                     :total="totals"
                     style="float:right;">
			</el-pagination>
		</el-col>



	</section>
</template>

<script>
	import util from '../../common/js/util'
	//import NProgress from 'nprogress'
	 import { getLogsListPage, removeLogs, batchRemoveLogs, editLogs, addLogs } from '../../api/api';

	export default {
		data() {
			return {
        // 日志查询
				filters: {
          keyword: ''
				},
        logs: [], // 日志数据
				totals: 0, // 日志数据总条数
        pageSize: 5, // 日志每页展示条数
        currentPage:1, // 日志页码
				listLoading: false, // 忙等关闭
      }
		},
		methods: {
      // 日志查询函数
      search() {
        this.currentPage=1
        this.getLogs()
      },

			// 页码触发事件
			handleCurrentChange(val) {
				this.currentPage = val;
				this.getLogs();
			},

			//获取日志数据
			getLogs() {
				let para = {
          pageSize: this.pageSize,
          currentPage:this.currentPage,
          keyword: this.filters.keyword
				};
				this.listLoading = true;
			  // 发送axios请求并且获取后端所有数据
        this.$http.post("/sys", para)
        .then(result=>{
          this.listLoading=false // 页表展示关闭忙等,因为在data总开启了忙等，发情请求就直接给data中的字段赋值
          this.logs=result.data.rows
          this.totals=result.data.totals
        })
        .catch(result=>{
          this.$message({
            message: '系统繁忙,请稍后重试!',
            type: 'error'
          });
        })
			},



    },

    // 钩子函数
		mounted() {
      // 日志数据
      this.getLogs();
     

		}
	}

</script>

<style scoped>

</style>